﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.Unity.InterceptionExtension;
using System.Collections.Concurrent;
using Thallo.Configuration;
namespace Thallo {
    internal static class BackingStoreManager {

        static object _sync = new object();
        static HashSet<string> _storedKeys = new HashSet<string>();

        public static void SyncCacheKeys(string key) {
            if (!_storedKeys.Contains(key))
                lock (_sync) {
                    if (!_storedKeys.Contains(key))
                        _storedKeys.Add(key);
                }
        }
        
        public static ICacheManager GetStore() {
            return GetStore(ThalloSection.Current.Storeage ?? "thallo");  
        }

        public static ICacheManager GetStore(string name) {
            return Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(name);
        }

    }
}
